<?php
/**
 * @author Anthony Free
 * @since 20120716
 * @package eclipsemde
 * @subpackage core
 */

/*
 * 
 */
require_once('Project.php');
require_once('InvalidProjectException.php');
/**
 * Handles all created instances of the projects in an easy to use class (Caching)
 * API-Like: $project_identifier used instead of internals etc etc
 * @author Anthony Free
 * @package eclipsemde
 * @subpackage core
 */
class ProjectStash extends StashMap {    
    /**
     * Constructor for the projectstash class
     * @since 20120716
     */
    protected function SingletonConstruct() {}
    
    /**
     * Destructor for the class 
     */
    public function __destruct() {}

    /**
     * Getter by identifier
     * @param string/integer $identifier
     * @return boolean
     * @throws InvalidProjectException 
     */
    public function get($identifier) {
	try {
	    return parent::get($identifier);
	} catch(StashMapException $e) {
	    throw new InvalidProjectException("Caused by ".$e->getMessage());
	    return false;
	}
    }
    
    /**
     * Stasher, add to the stash.
     * @param string/integer $identifier
     * @param boolean $force_restash
     * @return boolean
     * @throws InvalidProjectException 
     */
    public function stash($identifier, $force_restash = false) {
	try {
	    return parent::stash($identifier, 'Project', $force_restash);
	} catch(StashMapException $e) {
	    throw new InvalidProjectException("Caused by ".$e->getMessage());
	    return false;
	}
    }
    
}
$ProjectStash = Singleton::CreateInstance('ProjectStash');
?>
